home *** CD-ROM | disk | FTP | other *** search
/ Deutsche Edition 1 / Deutsche Edition 1.iso / amok / 001-010 / amok08 / blitter / blitter.mod < prev    next >
Text File  |  1993-11-04  |  3KB  |  121 lines

  1. MODULE Blitter;
  2.  
  3. FROM SYSTEM    IMPORT ADR, ADDRESS, SHIFT, BITSET, CAST;
  4.  
  5. FROM Dos       IMPORT Delay;
  6.  
  7. FROM Graphics  IMPORT OwnBlitter, DisownBlitter, WaitBlit, ViewModes,
  8.                       ViewModeSet, RastPortPtr, Draw, Move, DrawModes,
  9.                       DrawModeSet, SetDrMd;
  10.  
  11. FROM Hardware  IMPORT Custom;
  12.  
  13. FROM Intuition IMPORT OpenScreen, CloseScreen, customScreen, NewScreen,
  14.                       ScreenPtr, CurrentTime;
  15.  
  16. FROM InOut     IMPORT WriteInt, WriteString, WriteLn;
  17.  
  18. VAR
  19.   NuScreen: NewScreen;
  20.   Screen: ScreenPtr;
  21.   custom [0DFF000H]: Custom;
  22.   Oktant: ARRAY[0..7] OF CARDINAL;
  23.   i: INTEGER;
  24.   x0,y0,x1,y1: INTEGER;
  25.   Secs,secs,Micros,micros: LONGINT;
  26.  
  27. (*------  Let Blitter draw a Line:  ------*)
  28. (* $V- $R- $S- *)
  29.  
  30. PROCEDURE BlitLine(x0,y0,x1,y1:INTEGER; Plane: ADDRESS; Width: INTEGER);
  31.  
  32. VAR
  33.   exg: INTEGER;
  34.   Okt: CARDINAL;
  35.  
  36. BEGIN
  37.   INC(Plane,Width*y0 + SHIFT(CAST(INTEGER,{4..15} * CAST(BITSET,x0)),-3));
  38.   Okt := 0;
  39.   DEC(y1,y0);
  40.   IF y1<0 THEN
  41.     y1 := - y1;
  42.     INC(Okt,4);
  43.   END;
  44.   DEC(x1,x0);
  45.   IF x1<0 THEN
  46.     x1 := - x1;
  47.     INC(Okt,2);
  48.   END;
  49.   IF x1>y1 THEN
  50.     exg := x1; x1 := y1; y1 := exg;
  51.     INC(Okt);
  52.   END;
  53.   Okt := Oktant[Okt];
  54.   INC(x1,x1);
  55.   WITH custom DO
  56.     WHILE 14 IN dmaconr DO END;
  57.     dmacon := {15,10,6};
  58.     bltbmod := x1;
  59.     DEC(x1,y1);
  60.     IF x1<0 THEN INC(Okt,64) END;
  61.     bltapt  := ADDRESS(CAST(CARDINAL,x1));
  62.     bltamod := CAST(CARDINAL,x1-y1);
  63.     bltadat := 08000H;
  64.     bltbdat := 0FFFFH;
  65.     bltafwm := 0FFFFH;
  66.     bltcon0 := CAST(BITSET,SHIFT(CAST(CARDINAL,CAST(BITSET,x0)*{0..3}),12) + 0B4AH);
  67.     bltcon1 := CAST(BITSET,Okt);
  68.     bltcpt  := Plane;
  69.     bltdpt  := Plane;
  70.     bltcmod := Width;
  71.     bltdmod := Width;
  72.     bltsize := SHIFT(y1+1,6)+2;
  73.   END;   (* WITH Custom DO *)
  74. END BlitLine;
  75. (* $V+ $R+ $S+ *)
  76.  
  77.  
  78. BEGIN
  79.   Oktant[0] :=  1;
  80.   Oktant[1] := 17;
  81.   Oktant[2] :=  9;
  82.   Oktant[3] := 21;
  83.   Oktant[4] :=  5;
  84.   Oktant[5] := 25;
  85.   Oktant[6] := 13;
  86.   Oktant[7] := 29;
  87.   WITH NuScreen DO
  88.     leftEdge := 0; topEdge := 0; width := 320; height := 256; depth := 1;
  89.     detailPen := 0; blockPen := 1;
  90.     viewModes := ViewModeSet{};
  91.     type := customScreen;
  92.     font := NIL;
  93.     defaultTitle := ADR("Blitter");
  94.     gadgets := NIL;
  95.     customBitMap := NIL;
  96.   END;
  97.   Screen := OpenScreen(NuScreen);
  98.   OwnBlitter();
  99.   WITH Screen^.bitMap DO
  100.     CurrentTime(ADR(Secs),ADR(Micros));
  101.     FOR i:=0 TO 31 DO
  102.       FOR x0:=0 TO 319 DO
  103.         BlitLine(  0,  0, x0,255,planes[0],bytesPerRow);
  104.         BlitLine( x0,255,319,  0,planes[0],bytesPerRow);
  105.         BlitLine(  0,255, x0,  0,planes[0],bytesPerRow);
  106.         BlitLine( x0,  0,319,255,planes[0],bytesPerRow);
  107.       END;
  108.     END;
  109.   END;
  110.   CurrentTime(ADR(secs),ADR(micros));
  111.   DisownBlitter();
  112.   IF micros<Micros THEN
  113.     INC(micros,1000000);
  114.     DEC(secs,1);
  115.   END;
  116.   WriteString("This took");
  117.   WriteInt(secs-Secs,3); WriteString(" seconds and");
  118.   WriteInt(micros-Micros,7); WriteString(" micros."); WriteLn;
  119.   CloseScreen(Screen);
  120. END Blitter.
  121.